ADC
 
 
 Bean ADC
 
A/D converter

Application Notes, Tips and Tricks for the bean. Hints for code optimization.

Application Notes:



(1) Inappropriate use of Measure(TRUE) or MeasureChan(TRUE) call can lead to application dead-lock.
I.e. in polling mode (Interrupt service is disabled) the application stucks in Measure method, if Disable method is called from an event of other bean, or the speed mode is switched to a mode where the ADC bean is disabled while a measurement launched by Measure(TRUE) method is in progress.
Or if method Measure(TRUE) is called from an event of some bean and the priority of the interrupt of ADC bean isn't higher than the priority of this event (Interrupt service is enabled), this method will stuck.


Version specific information for HCS12 derivatives

(2) Problem with clearing External Trigger Overrun Flag
There is an issue concerning clearing of the ETORF flag. According to the datasheet writing 1 into the corresponding bit clears the ETORF flag. However this method fails on some versions of the HCS12 family (e.g. DP256B and others, see errata). It wasn't possible to use an alternative clearing method in all configurations of the ADC bean. As a result on some HCS12 derivatives the OnTrgOverrun event may be called inadvertently several times, because the ETORF flag is not cleared correctly.
If selected CPU is affected by this problem in AD converter (see errata) the clearing of the ETORF flag can be ensured by writing to a control register of the AD converter in the OnTrgOverrun event. This can be accomplished e.g. by sequential calling of Disable and Enable methods, or by calling Stop method followed by calling of a measuring method.

Example 1:

EVENTS.C

void AD_OnTrgOverrun(void)
{
  AD_Disable();
  AD_Enable();
  ........
}

Example 2:

EVENTS.C

void AD_OnTrgOverrun(void)
{
  AD_Stop();
  AD_EnableExtTrigger();
  ........
}



Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.